//
//  ProductDetailView.m
//  Finance
//
//  Created by cheng xiang on 13-4-7.
//  Copyright (c) 2013年 cheng xiang. All rights reserved.
//

#import "ProductDetailView.h"
#import <QuartzCore/QuartzCore.h>
#import "AnalysisJson.h"
#import "MultiThreading.h"
#import "AppDelegate.h"


@implementation ProductDetailView
@synthesize proId = _proId;
@synthesize banknameLabel = _banknameLabel, subjectLabel = _subjectLabel, titleLabel = _titleLabel, imageView = _imageView, currencyLabel = _currencyLabel, beginTimeLabel = _beginTimeLabel, endTimeLabel = _endTimeLabel, startMoneyLabel = _startMoneyLabel, mgrperiodLabel = _mgrperiodLabel, targetLabel = _targetLabel, ideaLabel = _ideaLabel, attentionsLabel = _attentionsLabel, facevalueLabel = _facevalueLabel, fareLabel = _fareLabel, managerprofileLabel = _managerprofileLabel,typeIdLabel = _typeIdLabel,transType = _transType;
@synthesize scrollView = _scrollView,bgView1 = _bgView1,bgView2 = _bgView2;
@synthesize proidLabel = _proidLabel;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, 44)];
        UIImage *root_image = [UIImage imageNamed:@"toolbar.jpg"];
        if ([toolbar respondsToSelector:@selector(setBackgroundImage:forToolbarPosition:barMetrics:)]) {
            [toolbar setBackgroundImage:root_image forToolbarPosition:0 barMetrics:0];         //仅5.0以上版本适用
        }else{
            toolbar.barStyle = UIToolbarPositionTop;
        }
        UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStyleBordered target:self action:@selector(goReturn)];
        UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
        UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"添加到关注" style:UIBarButtonItemStyleBordered target:self action:@selector(addItem)];
        [leftItem setBackgroundImage:[UIImage imageNamed:@"btn.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
        [rightItem setBackgroundImage:[UIImage imageNamed:@"btn.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
        toolbar.items = [NSArray arrayWithObjects:leftItem,spaceItem,rightItem, nil];
        [self addSubview:toolbar];
        
        _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 44, self.bounds.size.width, self.bounds.size.height-44)];
        UIColor* bk = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"beij.png"]];
        [_scrollView setBackgroundColor:bk];
        [self addSubview:_scrollView];
        
        UIImageView *bgview = [[UIImageView alloc] initWithFrame:CGRectMake(-5, 0, 330, 51)];
        [bgview setImage:[[UIImage imageNamed:@"searchbar.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)]];
        [_scrollView addSubview:bgview];
        
        _subjectLabel = [[UILabel alloc] initWithFrame:CGRectMake(140, 5, 175, 40)];
        _subjectLabel.numberOfLines = 0;
        _subjectLabel.lineBreakMode = NSLineBreakByWordWrapping;
        [_subjectLabel setBackgroundColor:[UIColor clearColor]];
        _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 5, 120, 40)];
        
        UIImageView *celltextbgView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 55, 310, 190)];
        [celltextbgView setImage:[[UIImage imageNamed:@"celltextbg.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)]];
        [_scrollView addSubview:celltextbgView];
        
        UIImageView *desView = [[UIImageView alloc] initWithFrame:CGRectMake(159, 58, 1, 175)];
        [desView setImage:[UIImage imageNamed:@"desLine.png"]];
        [_scrollView addSubview:desView];
        
        UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, 70, 25)];
        title.text = @"托管期限";
        title.font = [UIFont systemFontOfSize:13];
        title.backgroundColor = [UIColor clearColor];
        title.textColor = [UIColor brownColor];
        [_scrollView addSubview:title];
        _mgrperiodLabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 60, 80, 25)];
        _mgrperiodLabel.textAlignment = NSTextAlignmentRight;
        [_mgrperiodLabel setBackgroundColor:[UIColor clearColor]];
        UIImageView *lineImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 85, 300, 2)];
        lineImageView.image = [UIImage imageNamed:@"cellLine.png"];
        [_scrollView addSubview:lineImageView];
        
        title = [[UILabel alloc] initWithFrame:CGRectMake(165, 60, 70, 25)];
        title.text = @"面值";
        title.font = [UIFont systemFontOfSize:13];
        title.backgroundColor = [UIColor clearColor];
        title.textColor = [UIColor brownColor];
        [_scrollView addSubview:title];
        _facevalueLabel = [[UILabel alloc] initWithFrame:CGRectMake(235, 60, 75, 25)];
        _facevalueLabel.textAlignment = NSTextAlignmentRight;
        [_facevalueLabel setBackgroundColor:[UIColor clearColor]];
        
        title = [[UILabel alloc] initWithFrame:CGRectMake(10, 90, 70, 25)];
        title.text = @"币种";
        title.font = [UIFont systemFontOfSize:13];
        title.backgroundColor = [UIColor clearColor];
        title.textColor = [UIColor brownColor];
        [_scrollView addSubview:title];
        _currencyLabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 90, 80, 25)];
        _currencyLabel.textAlignment = NSTextAlignmentRight;
        [_currencyLabel setBackgroundColor:[UIColor clearColor]];
        lineImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 115, 300, 2)];
        lineImageView.image = [UIImage imageNamed:@"cellLine.png"];
        [_scrollView addSubview:lineImageView];
        
        title = [[UILabel alloc] initWithFrame:CGRectMake(165, 90, 70, 25)];
        title.text = @"费用";
        title.font = [UIFont systemFontOfSize:13];
        title.backgroundColor = [UIColor clearColor];
        title.textColor = [UIColor brownColor];
        [_scrollView addSubview:title];
        _fareLabel = [[UILabel alloc] initWithFrame:CGRectMake(235, 90, 75, 25)];
        _fareLabel.textAlignment = NSTextAlignmentRight;
        [_fareLabel setBackgroundColor:[UIColor clearColor]];
        
        title = [[UILabel alloc] initWithFrame:CGRectMake(10, 120, 70, 25)];
        title.text = @"起售金额";
        title.font = [UIFont systemFontOfSize:13];
        title.backgroundColor = [UIColor clearColor];
        title.textColor = [UIColor brownColor];
        [_scrollView addSubview:title];
        _startMoneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 120, 80, 25)];
        _startMoneyLabel.textAlignment = NSTextAlignmentRight;
        [_startMoneyLabel setBackgroundColor:[UIColor clearColor]];
        lineImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 145, 300, 2)];
        lineImageView.image = [UIImage imageNamed:@"cellLine.png"];
        [_scrollView addSubview:lineImageView];
        
        title = [[UILabel alloc] initWithFrame:CGRectMake(165, 120, 70, 25)];
        title.text = @"产品代码";
        title.font = [UIFont systemFontOfSize:13];
        title.backgroundColor = [UIColor clearColor];
        title.textColor = [UIColor brownColor];
        [_scrollView addSubview:title];
        _proidLabel = [[UILabel alloc] initWithFrame:CGRectMake(235, 120, 75, 25)];
        _proidLabel.textAlignment = NSTextAlignmentRight;
        [_proidLabel setBackgroundColor:[UIColor clearColor]];
        
        title = [[UILabel alloc] initWithFrame:CGRectMake(10, 150, 70, 25)];
        title.text = @"发行银行";
        title.font = [UIFont systemFontOfSize:13];
        title.backgroundColor = [UIColor clearColor];
        title.textColor = [UIColor brownColor];
        [_scrollView addSubview:title];
        _banknameLabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 150, 80, 25)];
        _banknameLabel.textAlignment = NSTextAlignmentRight;
        [_banknameLabel setBackgroundColor:[UIColor clearColor]];
        [_banknameLabel setFont:[UIFont systemFontOfSize:13]];
        lineImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 175, 300, 2)];
        lineImageView.image = [UIImage imageNamed:@"cellLine.png"];
        [_scrollView addSubview:lineImageView];
        
        title = [[UILabel alloc] initWithFrame:CGRectMake(165, 150, 80, 25)];
        title.text = @"信息关注次数";
        title.font = [UIFont systemFontOfSize:13];
        title.backgroundColor = [UIColor clearColor];
        title.textColor = [UIColor brownColor];
        [_scrollView addSubview:title];
        _attentionsLabel = [[UILabel alloc] initWithFrame:CGRectMake(245, 150, 65, 25)];
        _attentionsLabel.font = [UIFont systemFontOfSize:13];
        _attentionsLabel.textAlignment = NSTextAlignmentRight;
        [_attentionsLabel setBackgroundColor:[UIColor clearColor]];
        
        title = [[UILabel alloc] initWithFrame:CGRectMake(10, 180, 60, 50)];
        title.text = @"开始销售时间";
        title.font = [UIFont fontWithName:@"MicrosoftYaHei" size:13];
         //title.textColor = [UIColor colorWithRed:120 green:12 blue:9 alpha:255];
        title.backgroundColor = [UIColor clearColor];
       
        title.numberOfLines = 0;
        title.lineBreakMode = NSLineBreakByWordWrapping;
        title.textColor = [UIColor brownColor];
        [_scrollView addSubview:title];
        _beginTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(70, 180, 90, 50)];
        _beginTimeLabel.numberOfLines = 0;
        _beginTimeLabel.lineBreakMode = NSLineBreakByWordWrapping;
        _beginTimeLabel.textAlignment = NSTextAlignmentRight;
        [_beginTimeLabel setBackgroundColor:[UIColor clearColor]];
        
        title = [[UILabel alloc] initWithFrame:CGRectMake(165, 180, 60, 50)];
        title.text = @"截止销售时间";
        title.font = [UIFont systemFontOfSize:13];
        title.backgroundColor = [UIColor clearColor];
        title.numberOfLines = 0;
        title.lineBreakMode = NSLineBreakByWordWrapping;
        title.textColor = [UIColor brownColor];
        [_scrollView addSubview:title];
        _endTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(220, 180, 90, 50)];
        _endTimeLabel.textAlignment = NSTextAlignmentRight;
        _endTimeLabel.numberOfLines = 0;
        _endTimeLabel.lineBreakMode = NSLineBreakByWordWrapping;
        [_endTimeLabel setBackgroundColor:[UIColor clearColor]];

        celltextbgView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 250, 310, 40)];
        [celltextbgView setImage:[[UIImage imageNamed:@"celltextbg.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)]];
        [_scrollView addSubview:celltextbgView];
        
        title = [[UILabel alloc] initWithFrame:CGRectMake(10, 260, 60, 20)];
        title.text = @"投资目标";
        title.font = [UIFont systemFontOfSize:13];
        title.backgroundColor = [UIColor clearColor];
        title.numberOfLines = 0;
        title.lineBreakMode = NSLineBreakByWordWrapping;
        title.textColor = [UIColor brownColor];
        [_scrollView addSubview:title];
        
        _targetLabel = [[UILabel alloc] initWithFrame:CGRectMake(70, 260, 230, 20)];
        _targetLabel.textAlignment = NSTextAlignmentRight;
        //_targetLabel.font = [UIFont systemFontOfSize:13];
        _targetLabel.font = [UIFont fontWithName:@"MicrosoftYaHei" size:13];
        [_targetLabel setBackgroundColor:[UIColor clearColor]];
        
        
        UIImage *textbgImage = [UIImage imageNamed:@"celltextbg.png"];
        _bgView1 = [[UIImageView alloc] initWithFrame:CGRectZero];
        _bgView2 = [[UIImageView alloc] initWithFrame:CGRectZero];
        _bgView3 = [[UIImageView alloc] initWithFrame:CGRectZero];
        
        
//        _banknameLabel = [[UILabel alloc] initWithFrame:CGRectMake(165, 5, 140, 20)];
//        [_banknameLabel setBackgroundColor:[UIColor clearColor]];
//        _targetLabel = [[UILabel alloc] initWithFrame:CGRectMake(165, 30, 120, 20)];
//        [_targetLabel setBackgroundColor:[UIColor clearColor]];
//        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, 180, 20)];
//         [_titleLabel setBackgroundColor:[UIColor clearColor]];
//        _currencyLabel = [[UILabel alloc] initWithFrame:CGRectMake(190, 60, 100, 20)];
//         [_currencyLabel setBackgroundColor:[UIColor clearColor]];
//        _beginTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 85, 150, 20)];
//        [_beginTimeLabel setBackgroundColor:[UIColor clearColor]];
//        _endTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(160, 85, 150, 20)];
//         [_endTimeLabel setBackgroundColor:[UIColor clearColor]];
//        _startMoneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 110, 150, 20)];
//         [_startMoneyLabel setBackgroundColor:[UIColor clearColor]];
        
        _ideaLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        [_ideaLabel setBackgroundColor:[UIColor clearColor]];
        _bgView1.image = [textbgImage resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
        _ideaLabel.clipsToBounds = NO;
        [_scrollView addSubview:_bgView1];
        _ideaLabel.lineBreakMode = NSLineBreakByWordWrapping;
        _ideaLabel.numberOfLines = 0;
//        _attentionsLabel = [[UILabel alloc] initWithFrame:CGRectZero];
//         [_attentionsLabel setBackgroundColor:[UIColor clearColor]];
//        _typeIdLabel = [[UILabel alloc] initWithFrame:CGRectZero];
//         [_typeIdLabel setBackgroundColor:[UIColor clearColor]];
//        _facevalueLabel = [[UILabel alloc] initWithFrame:CGRectZero];
//         [_facevalueLabel setBackgroundColor:[UIColor clearColor]];
//        _fareLabel = [[UILabel alloc] initWithFrame:CGRectZero];
//        [_fareLabel setBackgroundColor:[UIColor clearColor]];
        _managerprofileLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        [_managerprofileLabel setBackgroundColor:[UIColor clearColor]];
        _managerprofileLabel.lineBreakMode = NSLineBreakByWordWrapping;
        _managerprofileLabel.numberOfLines = 0;
        _bgView2.image = [textbgImage resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
        _managerprofileLabel.clipsToBounds = NO;
        [_scrollView addSubview:_bgView2];
        
        _typeIdLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        [_typeIdLabel setBackgroundColor:[UIColor clearColor]];
        _typeIdLabel.textAlignment = NSTextAlignmentRight;
        _typeIdLabel.lineBreakMode = NSLineBreakByWordWrapping;
        _typeIdLabel.numberOfLines = 0;
        _bgView3.image = [textbgImage resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
        _typeIdLabel.clipsToBounds = NO;
        [_scrollView addSubview:_bgView3];
        
        _titleLab = [[UILabel alloc] initWithFrame:CGRectZero];
        _titleLab.text = @"产品编号";
        _titleLab.font = [UIFont systemFontOfSize:13];
        _titleLab.backgroundColor = [UIColor clearColor];
        _titleLab.numberOfLines = 0;
        _titleLab.lineBreakMode = NSLineBreakByWordWrapping;
        _titleLab.textColor = [UIColor brownColor];
        [_scrollView addSubview:_titleLab];
        
        
        [bgview addSubview:_imageView];
        [_scrollView addSubview:_banknameLabel];
        [_scrollView addSubview:_subjectLabel];
//        [_scrollView addSubview:_titleLabel];
        [_scrollView addSubview:_currencyLabel];
        [_scrollView addSubview:_beginTimeLabel];
        [_scrollView addSubview:_endTimeLabel];
        [_scrollView addSubview:_startMoneyLabel];
        [_scrollView addSubview:_mgrperiodLabel];
        [_scrollView addSubview:_targetLabel];
        [_scrollView addSubview:_ideaLabel];
        [_scrollView addSubview:_attentionsLabel];
        [_scrollView addSubview:_typeIdLabel];
        [_scrollView addSubview:_facevalueLabel];
        [_scrollView addSubview:_fareLabel];
        [_scrollView addSubview:_managerprofileLabel];
        [_scrollView addSubview:_proidLabel];
        
        self.backgroundColor = [UIColor whiteColor];
        
        AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
        UITabBarController *aController = (UITabBarController *)delegate.window.rootViewController;
        [delegate hideTabBar:aController];
    }
    return self;
}

- (void)goReturn
{
    AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    UITabBarController *aController = (UITabBarController *)delegate.window.rootViewController;
    [delegate showTabBar:aController];
    
    CATransition *transion = [CATransition animation];
    transion.duration = 0.3;
    transion.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
    transion.type = kCATransitionFade;
    [self.superview.layer addAnimation:transion forKey:nil];
    [self removeFromSuperview];
}

- (void)addItem
{
    if (self.proId == nil || [self.proId isEqualToString:@""] ) {
        return;
    }
    AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    if (delegate.loginSessionID == nil || [delegate.loginSessionID isEqualToString:@""]) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"您还没有登录，请登录后再尝试添加到关注" delegate:self cancelButtonTitle:@"好的" otherButtonTitles: nil];
        [alert show];
    }else{
        [self packageRequest:@"W109"];
    }
    
}


- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    UITabBarController *tabBarController =
    (UITabBarController *)delegate.window.rootViewController;
    [tabBarController setSelectedIndex:4];
}

- (void)getDataForId :(NSString *)proId
{
    self.proId = proId;
    [self packageRequest:@"W103"];
}

- (void)drawView :(NSDictionary *)dic
{
    self.proId = [dic objectForKey:@"prodId"];
    [self putTextToView:dic];
}

- (void)packageRequest: (NSString *)transType
{
    //组请求报文
    self.transType = transType;
    NSString *server = @"";
    NSDictionary *header = [AnalysisJson PackageJsonHeader:transType];
    if ([@"W103" isEqualToString:transType]) {
        server = @"QueryProdDetail";
    }else if([@"W109" isEqualToString:transType]){
        server = @"AddUserAttention";
    }
    NSDictionary *body = [self PackageBody:self.proId];
    NSData *requestJson = [AnalysisJson PackageJsonFromHeader:header andBody:body];
    
    //发送报文
    [self getTableData: requestJson server:server];
}

//每次组报文需要实现类似组body的方法
- (NSDictionary *)PackageBody:(NSString *)proId
{
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setObject:proId forKey:@"prodId"];
    
    if ([_transType isEqualToString:@"W109"]) {
        AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
        if (delegate.loginSessionID == nil || [delegate.loginSessionID isEqualToString:@""]) {
            
        }else{
            [dic setObject:delegate.loginSessionID forKey:@"sessionId"];
        }
    }
    
    return dic;
}

- (void)getTableData:(NSData *)data server:(NSString *)server
{
    [MultiThreading getDataFromNetwork:[SERVICE_URL stringByAppendingString:server] toObject:self callBack:@selector(requestCallBack:) withBody:data];
}

- (void)requestCallBack:(NSDictionary *)dic
{
    NSDictionary *head = [dic objectForKey:@"header"];
    NSString *transType = [head objectForKey:@"transType"];
    if ([transType isEqualToString:@"W109"]) {
        NSString *returnMsg = [head objectForKey:@"returnMessage"];
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"添加结果" message:returnMsg delegate:nil cancelButtonTitle:@"好的" otherButtonTitles: nil];
        [alert show];
    }else if([@"W103" isEqualToString:transType]){
        NSDictionary *detailDic = nil;
        NSObject *body = dic[@"body"];
        if([body isKindOfClass:[NSDictionary class]] && [(NSDictionary *)body objectForKey:@"product"] != nil)
        {
            detailDic = [(NSDictionary *)body objectForKey:@"product"];
        }
        [self putTextToView:detailDic];
    }
    
}

- (void)drawBankImage:(NSObject *)obj
{
    if ([obj isKindOfClass:[NSString class]]) {
        NSString *imageurl = (NSString *)obj;
        //UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageurl]]];后面使用这个url的方法
        UIImage *image = [UIImage imageWithContentsOfFile:imageurl];
        [_imageView performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:NO];
    }
}

- (void)putTextToView:(NSDictionary *)detailDic
{
    [NSThread detachNewThreadSelector:@selector(drawBankImage:) toTarget:self withObject:[[NSBundle mainBundle] pathForResource:@"testImage" ofType:@"jpg"]];
    //[dic objectForKey:@"imageUrl"]到时候用这个替换
    _banknameLabel.text = [detailDic objectForKey:@"bankName"];
    _subjectLabel.text = [detailDic objectForKey:@"subject"];
//    _titleLabel.text = [detailDic objectForKey:@"title"];
    _currencyLabel.text = [NSString stringWithFormat:@"%@",[detailDic objectForKey:@"currency"]];
    _beginTimeLabel.text = [detailDic objectForKey:@"beginTime"];
    _endTimeLabel.text = [detailDic objectForKey:@"endTime"];
    _startMoneyLabel.text = [NSString stringWithFormat:@"%@",[detailDic objectForKey:@"startMoney"]];
    _mgrperiodLabel.text = [NSString stringWithFormat:@"%@",[detailDic objectForKey:@"mgrPeriod"]];
    _targetLabel.text = [detailDic objectForKey:@"target"];
    _ideaLabel.text = [NSString stringWithFormat:@"投资理念:%@",[detailDic objectForKey:@"idea"]];
    _proidLabel.text = [detailDic objectForKey:@"prodId"];
    //动态更新label高度
    CGSize textSize = [_ideaLabel.text sizeWithFont:_ideaLabel.font constrainedToSize:CGSizeMake(300, 999) lineBreakMode:NSLineBreakByWordWrapping];
    [_ideaLabel setFrame:CGRectMake(20, 310, 280, textSize.height)];
    _bgView1.frame = CGRectMake(_ideaLabel.frame.origin.x-15, _ideaLabel.frame.origin.y-15, _ideaLabel.bounds.size.width+30, _ideaLabel.bounds.size.height+30);
    
    _attentionsLabel.text = [NSString stringWithFormat:@"%@",[detailDic objectForKey:@"attentions"]];
    //_attentionsLabel.frame = CGRectMake(10, _ideaLabel.frame.origin.y+_ideaLabel.frame.size.height+25, 150, 20);
    _typeIdLabel.text = [NSString stringWithFormat:@"%@",[detailDic objectForKey:@"typeId"]];
    //_typeIdLabel.frame = CGRectMake(160, _ideaLabel.frame.origin.y+_ideaLabel.frame.size.height+25, 150, 20);
    _facevalueLabel.text = [NSString stringWithFormat:@"%@",[detailDic objectForKey:@"faceValue"]];
    //_facevalueLabel.frame = CGRectMake(10, _ideaLabel.frame.origin.y+_ideaLabel.frame.size.height+50, 150, 20);
    _fareLabel.text = [NSString stringWithFormat:@"%@",[detailDic objectForKey:@"fare"]];
    //_fareLabel.frame = CGRectMake(160, _ideaLabel.frame.origin.y+_ideaLabel.frame.size.height+50, 150, 20);
    _managerprofileLabel.text = [detailDic objectForKey:@"managerProfile"];
    textSize = [_managerprofileLabel.text sizeWithFont:_managerprofileLabel.font constrainedToSize:CGSizeMake(300, 999) lineBreakMode:NSLineBreakByWordWrapping];
    [_managerprofileLabel setFrame:CGRectMake(20, _ideaLabel.frame.origin.y+_ideaLabel.frame.size.height+30, 280, textSize.height)];
    _bgView2.frame = CGRectMake(_managerprofileLabel.frame.origin.x-15, _managerprofileLabel.frame.origin.y-15, _managerprofileLabel.bounds.size.width+30, _managerprofileLabel.bounds.size.height+30);
    

    _typeIdLabel.frame = CGRectMake(90, _managerprofileLabel.frame.origin.y+_managerprofileLabel.frame.size.height+30, 210, 20);
    _bgView3.frame = CGRectMake(_typeIdLabel.frame.origin.x-85, _typeIdLabel.frame.origin.y-15, _typeIdLabel.bounds.size.width+100, _typeIdLabel.bounds.size.height+30);
    _titleLab.frame = CGRectMake(20, _managerprofileLabel.frame.origin.y+_managerprofileLabel.frame.size.height+30, 70, 20);
    _scrollView.contentSize = CGSizeMake(320, _typeIdLabel.frame.origin.y+_typeIdLabel.frame.size.height+30);
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
